package com.ipharma.dto;

import com.ipharma.application.services.transaccion.Item;

/**
 * A Product class.
 * <P>
 * @author JorgE.H
 */
public class Product extends Item
{
  /**
   * Attributes
   */
  protected boolean available = false;
  protected String row = "";
  protected String column = "";
  protected int id;
  protected int maxQty;

  /**
   * Constructor
   */
  public Product()
  {
  }

  /**
   * Constructor
   * @param pDesc product description
   * @param pQty product quantity
   * @param pCode product code
   * @param pAvailable product disponibility
   */
  public Product( String pDesc, int pQty, String pCode, boolean pAvailable )
  {
    description = new String( pDesc );
    quantity    = pQty;
    code        = new String( pCode );
    available   = pAvailable;
  }

  /**
   * Constructor
   * @param pDesc product description
   * @param pQty product quantity
   * @param pCode product code
   * @param pAvailable product disponibility
   * @param pRow position in dispenser
   * @param pColumn position in dispenser
   * @param pId product id
   */
  public Product( String pDesc, int pQty, String pCode, boolean pAvailable,
      String pRow, String pColumn )
  {
    description = new String( pDesc );
    quantity    = pQty;
    code        = new String( pCode );
    available   = pAvailable;
    row         = new String( pRow );
    column      = new String( pColumn );
  }

  /**
   * Returns product disponibility
   * @returns true if is available, false otherwise
   */
  public boolean isAvailable()
  {
    return available;
  }

  /**
   * Change product disponibility
   * @param pAvailable new state for disponibility
   */
  public void setAvailable( boolean pAvailable )
  {
    available = pAvailable;
  }

  /**
   * Returns row number
   * @returns int row number
   */
  public String getRow()
  {
    return row;
  }

  /**
   * Returns column number
   * @returns int column number
   */
  public String getColumn()
  {
    return column;
  }

  /**
   * Returns product id
   * @returns product id
   */
  public int getId()
  {
    return id;
  }

  /**
   * Sets max quantity
   * @param pMaxQty the maximun extraction quantity
   */
  public void setMaxQty( int pMaxQty )
  {
    maxQty = pMaxQty;
  }

  /**
   * Returns product maximun extraction quantity
   * @returns product maximun extraction quantity
   */
  public int getMaxQty()
  {
    return maxQty;
  }

  /**
   * Sets product id
   * @param pId the product id
   */
  public void setId( int pId )
  {
    id = pId;
  }

  /**
   * Copies the contents of pProd into this
   * @param the Product to copy data from
   */
  public void copy( Product pProd )
  {
    this.description = new String( pProd.getDescription() );
    this.code = new String( pProd.getCode() );
    this.id = pProd.getId();
    this.quantity = pProd.getQuantity();
    this.column = new String( pProd.getColumn() );
    this.row = new String( pProd.getRow() );
    this.maxQty = pProd.getMaxQty();
  }

  /**
   * Returns a copy of current instance
   * @return a cloned of this instance of Product
   */
  public Object clone()
  {
    Product l_new = new Product( description, quantity, code, available, row, column );
    l_new.setId( this.id );
    l_new.setMaxQty( this.maxQty );
    return l_new;
  }

}

